/*
 * Copyright (c) 2024-2024 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
#include "sched_event_loop.h"
#include "comm_def.h"
#include "iotc_log.h"
#include "iotc_errcode.h"

#define SCHED_EVENT_LOOP_NAME "SCHED_EL"
static EventLoop *g_wifiEventLoop = NULL;

int32_t SchedEventLoopInit(void)
{
    g_wifiEventLoop = EventLoopNew(SCHED_EVENT_LOOP_NAME);
    if (g_wifiEventLoop == NULL) {
        IOTC_LOGE("init event loop error");
        return IOTC_CORE_COMM_FWK_ERR_LOOP_NEW;
    }

    return IOTC_OK;
}

void SchedEventLoopDeinit(void)
{
    EventLoopFree(g_wifiEventLoop);
    g_wifiEventLoop = NULL;
}

EventLoop *GetSchedEventLoop(void)
{
    return g_wifiEventLoop;
}

IotcTaskId *GetSchedEventLoopTaskId(void)
{
    return EventLoopGetTaskId(g_wifiEventLoop);
}